<template>
  <div>
    <div class="title">1.用途：</div>
    <div class="content">
        VueUse useRefHistory 可以自动跟踪响应式对象的历史更改，还提供撤消和重做功能。
    </div>

    <div class="content">
      <p>Value：{{ value }}</p>
      <el-button @click="add">累加</el-button>
      <el-button @click="undo">撤销</el-button>
    </div>

    <div class="title">提交记录：</div>
    <p class="content">{{ showHistory() }}</p>
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from "vue";
import { useRefHistory } from "@vueuse/core";
const value = ref(0);
const { undo, history } = useRefHistory(value, {
  capacity: 5,
});
const add = () => {
  value.value += 1;
};
const showHistory = () => {
  return history;
};
</script>

<style scoped>
.title {
  font-size: 18px;
  line-height: 60px;
  font-weight: bolder;
}
.content {
  margin-bottom: 20px;
  padding-left: 40px;
}
</style>